{% extends 'app/base.html' %}
{% load staticfiles %}

{% block cssinclude %}
{% endblock %}


{% block mainbody %}
    <div class="portlet box green">
        <div class="portlet-title">
            <div class="caption">
                <i class="icon-speedometer"></i>历史预测
            </div>
        </div>
        <div class="portlet-body">

            <div class="row">
                <div class="col-md-12">
                    {% if data is None %}
                        游客无法查看历史数据~~
                    {% else %}
                        <table id="description" class="table table-bordered tablle-striped">
                            <thead>
                            <tr>
                                <td>序号</td>
                                <td>结果</td>
                                <td>创建时间</td>
                                <td>参数</td>
                                <td>数据下载</td>
                            </tr>
                            </thead>
                            {% for item in data %}
                                <tr>
                                    <td>{{ forloop.counter }}</td>
                                    <td>{{ item.result }}</td>
                                    <td>{{ item.create_dt }}</td>
                                    <td>{{ item.args }}</td>
                                    <td><a onclick="down_info({{ item.data_id }})"> <i class="fa fa-cloud-download"></i>下载</a>
                                    </td>
                                </tr>
                            {% endfor %}
                        </table>
                    {% endif %}

                </div>
            </div>
        </div>
    </div>
{% endblock %}


{% block jsinclude %}
    <script>
        function down_info(data_id) {
            window.location.href = '/history_data?data_id=' + data_id;
        }

        {#csrf标签，防止ajax，post被拦截#}
        $.ajaxSetup({
            data: {csrfmiddlewaretoken: '{{ csrf_token }}'},
        });
    </script>
{% endblock %}